<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<form action="注册成功.html" id="form1">
			用户名:<input type="text" name="username" id="input1"/><br />
			密码:<input type="text" name="userpwd" id="input2"/><br />
			<input type="submit" />
			<input type="reset" />
		</form>
		
		<script>
			// onfocus 获得焦点
			input1.onfocus = function(){
				var obj = event.target;
				obj.style.backgroundColor = "red";
			}
			
			// onblur 失去焦点
			input1.onblur = function(){
				var obj = event.target;
				obj.style.backgroundColor = "white";
			}
			
			// onchange 失去焦点并且内容发生改变
			input1.onchange = function(){
				console.log('内容发生改变了');
			}
			
			form1.onsubmit = function(){
				console.log("表单提交了");
				return true;
			}
			
			// onreset 表单内容重置
			form1.onreset = function(){
				console.log('表单重置了');
			}
		</script>
		
	</body>
</html>
